<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Contact extends CI_Controller {

	function __construct(){
		  parent::__construct();
		  if(!isset($_SESSION)): session_start(); endif;
		  $this->load->model('users_model');
		  $this->load->model('recipients_model');
		  $this->load->helper('myuser_helper');
	}

	public function index()
	{
		$data['title']= "Sign in My Life My Eulogy";
		$data['main_content'] = 'misc/contact_view';
		$data['bottom_ads'] = Myuser_helper::getAds('bottom',1);
		$data['sidebar_ads'] = Myuser_helper::getAds('sidebar',2);
		$data['send'] = false;
		$post = $this->input->post();
		if(!empty($post)){
			$send_to = 'evan@advanzweb.com';
			$headers  = 'MIME-Version: 1.0' . "\r\n";
			$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
			$headers .= "From: ".$post['contact_name']."<".$post['contact_email']."> \r\n";
			$subject  = "My Life My Eulogy - ".$post['contact_subject'];
			$body  = '';
			$body .= '<div style="margin:10px 0 5px 0;">Hi Admin!</div>';
			$body .= '<div style="margin-bottom:5px;">Name:'.$post['contact_name'].'</div>';
			$body .= '<div style="margin-bottom:5px;">Message:</div>';
			$body .= '<div style="margin-left:10px;">'.$post['contact_message'].'</div>';
			$data['send'] = (mail($send_to, $subject, $body,$headers))? true:false;
		}//end if
		$this->load->view('includes/template', $data);
	}


	public function captcha_validate(){
	  $this->load->helper("captcha");
	  print_r(my_sessions());
	}

	function logout(){
		$this->session->sess_destroy();
		redirect('home');
	}


}// end of controller







